/**
 * Copyright (c) Software Institude of PKU
 * All rights reserved. 
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 */
package edu.pku.sei.modeler.model.uml.Kernel;
// imports:
import org.w3c.dom.Element;

import edu.pku.sei.modeler.model.common.MetaTypedList;
import edu.pku.sei.modeler.model.core.MetaModelElement;
import edu.pku.sei.modeler.model.xml.XMLUtility;
import edu.pku.sei.modeler.uml.modelHelper.ModelPackage;
import edu.pku.sei.modeler.uml.util.MetaTypedSet;



/**
 * @generated
 * modified by zsj
 */
public class DirectedRelationship extends MetaModelElement implements IDirectedRelationship {
	// attributes
	
	
	
	
	// references
	/**
	 * Specifies the sources of the DirectedRelationship. Subsets
	 * Relationship::relatedElement. This is a derived union.
	 * 
	 * modified by zsj-- change "protected" to "private" because it is derived
	 */
	private MetaTypedList target;
	
	/**
	 * Specifies the targets of the DirectedRelationship. Subsets Relationship::relatedElement.
	 * This is a derived union.
	 * 
	 * modified by zsj-- change "protected" to "private" because it is derived
	 */
	private MetaTypedList source;
	
	
	
	// getters & setters for attributes
	
	// getters for references
	
	public MetaTypedList getTarget() {
		if(target == null) {
			target = new MetaTypedSet(UMLElement.class, this, ModelPackage.DIRECTEDRELATIONSHIP_TARGET);
		}
		return target;
	}
	
	public MetaTypedList getSource() {
		if(source == null) {
			source = new MetaTypedSet(UMLElement.class, this, ModelPackage.DIRECTEDRELATIONSHIP_SOURCE);
		}
		return source;
	}
	
	// save & load
	public void serialize(Element root) {
		super.serialize(root);
		// attributes
		
		// references
		
		XMLUtility.xmlInstance.serializeNodesNotContain(root, ModelPackage.DIRECTEDRELATIONSHIP_TARGET, target);		
		
		XMLUtility.xmlInstance.serializeNodesNotContain(root, ModelPackage.DIRECTEDRELATIONSHIP_SOURCE, source);		
		
	}
	
	public void deSerialize(Element root) {
		super.deSerialize(root);
		// attributes
		
		// references
		
		this.getTarget().addAll(XMLUtility.xmlInstance.deSerializeNodesNotContain(root, ModelPackage.DIRECTEDRELATIONSHIP_TARGET, this));
		
		this.getSource().addAll(XMLUtility.xmlInstance.deSerializeNodesNotContain(root, ModelPackage.DIRECTEDRELATIONSHIP_SOURCE, this));
		
	}
	
	public void dynamicSet(String featureID, Object value) {
		if(featureID == null || "".equals(featureID)) {
			return;
		}
		// attributes
		
		// references
		
		else if(ModelPackage.DIRECTEDRELATIONSHIP_TARGET.equals(featureID)) {
			getTarget().add(value);
		}
		
		else if(ModelPackage.DIRECTEDRELATIONSHIP_SOURCE.equals(featureID)) {
			getSource().add(value);
		}
		
		else
			super.dynamicSet(featureID, value);
	}
}
 
 
 
 
 